package com.aaa.repast.product.controller;

import java.util.List;
import com.aaa.repast.web.controller.BaseController;
import com.aaa.repast.web.domain.AjaxResult;
import com.aaa.repast.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.aaa.repast.product.domain.Product;
import com.aaa.repast.product.service.IProductService;

/**
 * 商品 信息操作处理
 * 
 * @author teacherChen
 * @date 2020-01-03
 */
@RestController
@RequestMapping("/wx/product")
@Api(tags = "商品信息操作处理接口")
public class ProductController extends BaseController
{
	@Autowired
	private IProductService productService;
	/**
	 * 查询商品列表
	 */
    @ApiOperation(value = "查询商品列表")
    @ApiImplicitParam(name = "查询参数",value = "查询参数",dataTypeClass = Product.class)
	@PostMapping("/list")
	public TableDataInfo list(Product product)
	{
		startPage();
        List<Product> list = productService.selectProductList(product);
		return getDataTable(list);
	}
	
	

	

	/**
	 * 新增保存商品
	 */
    @ApiOperation(value = "新增保存商品")
    @ApiImplicitParam(name = "参数",value = "参数",dataTypeClass = Product.class)
	@PostMapping("/add")
	public AjaxResult addSave(Product product)
	{		
		return toAjax(productService.insertProduct(product));
	}


	/**
	 * 修改保存商品
	 */
    @ApiOperation(value = "修改保存商品")
    @ApiImplicitParam(name = "参数",value = "参数",dataTypeClass = Product.class)
	@PostMapping("/edit")
	public AjaxResult editSave(Product product)
	{		
		return toAjax(productService.updateProduct(product));
	}
	
	/**
	 * 删除商品
	 */
    @ApiOperation(value = "删除商品")
    @ApiImplicitParam(name = "参数",value = "参数",dataTypeClass = String.class)
	@PostMapping( "/remove")
	public AjaxResult remove(String ids)
	{		
		return toAjax(productService.deleteProductByIds(ids));
	}
	
}
